package com.csc.bankingsystem.core.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.csc.bankingsystem.core.enumeration.TransferRecordStatusEnum;
import com.csc.bankingsystem.core.enumeration.TransferRecordUnitEnum;
import com.fasterxml.jackson.annotation.JsonManagedReference;

/**
 * TransferRecord Data Transfer Object
 * 
 * @author angelkid
 *
 */
@Entity
@Table(name = "TRANSFERRECORD")
public class TransferRecord extends BankingSystemAbstractEntity {
	private AccountInfo source;
	private AccountInfo destination;
	private Date transDate;
	private Long amount;
	private TransferRecordUnitEnum unit;
	private String message;
	private TransferRecordStatusEnum status;
	private Long remainAmount;
	private HistoryRecord historyRecord;
	
	
	@Column(name = "transDate",nullable = false, length = 12)
	public Date getTransDate() {
		return transDate;
	}
	public void setTransDate(Date transDate) {
		this.transDate = transDate;
	}
	
	@Column(name = "amount",nullable = false, length = 12)
	public Long getAmount() {
		return amount;
	}
	public void setAmount(Long amount) {
		this.amount = amount;
	}

	@Column(name = "unit", nullable = false)
	@Enumerated(EnumType.STRING)
	public TransferRecordUnitEnum getUnit() {
		return unit;
	}
	public void setUnit(TransferRecordUnitEnum unit) {
		this.unit = unit;
	}
	
	@Column(name = "message",nullable = true, length = 500)
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	
	@Column(name = "status", nullable = false)
	@Enumerated(EnumType.STRING)
	public TransferRecordStatusEnum getStatus() {
		return status;
	}
	public void setStatus(TransferRecordStatusEnum status) {
		this.status = status;
	}
	
	@Column(name = "remainAmount",nullable = false, length = 12)
	public Long getRemainAmount() {
		return remainAmount;
	}
	public void setRemainAmount(Long remainAmount) {
		this.remainAmount = remainAmount;
	}

	@JsonManagedReference
	@ManyToOne
	@JoinColumn(name = "sourceId")
	public AccountInfo getSource() {
		return source;
	}
	public void setSource(AccountInfo source) {
		this.source = source;
	}
	
	@JsonManagedReference
	@ManyToOne
	@JoinColumn(name = "destinationId")
	public AccountInfo getDestination() {
		return destination;
	}
	public void setDestination(AccountInfo destination) {
		this.destination = destination;
	}
	
	@JsonManagedReference
	@OneToOne
	@JoinColumn(name="historyRecordId")
	public HistoryRecord getHistoryRecord() {
		return historyRecord;
	}
	public void setHistoryRecord(HistoryRecord historyRecord) {
		this.historyRecord = historyRecord;
	}
}
